<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateYsBooksTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('books', function(Blueprint $table)
		{
			$table->increments('id')->comment('主键id');
			$table->string('book_num', 32)->index('books_book_num_index')->comment('书籍编号');
			$table->bigInteger('uid')->comment('关联用户id');
			$table->string('name', 64)->comment('书名称');
			$table->tinyInteger('status')->nullable()->default(1)->comment('书籍状态0为已完结1为连载2为已删除');
			$table->tinyInteger('gender')->nullable()->default(0)->comment('0为男行1为女型');
			$table->integer('type')->nullable()->comment('书籍类型');
			$table->text('introduction')->nullable()->comment('简介');
			$table->string('labels')->nullable()->comment('标签');
			$table->string('cover')->nullable()->comment('封面图片');
			$table->tinyInteger('isrelease')->nullable()->default(2)->comment('是否已发布1为已发布2为审核中0未通过');
			$table->tinyInteger('isopen')->default(1)->comment('是否公开1为公开');
			$table->string('author', 64)->nullable()->comment('作者');
			$table->integer('read_counts')->nullable()->default(0)->comment('阅读次数');
			$table->tinyInteger('recommend')->nullable()->default(0)->comment('是否首页推荐1为推荐');
			$table->tinyInteger('book_review')->nullable()->default(0)->comment('官方书评1为有书评');
			$table->integer('review_time')->nullable()->comment('官方书评时间');
			$table->bigInteger('collection_counts')->unsigned()->nullable()->default(0)->comment('收藏次数');
			$table->integer('create_time')->nullable()->comment('创建时间');
			$table->integer('last_modify_time')->nullable()->default(0)->comment('最后更新时间');
			$table->timestamp('synced_at')->nullable()->comment('书籍最后的同步时间');
			$table->timestamp('recommended_at')->nullable()->comment('知书推荐时间');
			$table->timestamp('choiceness_at')->nullable()->comment('书籍添加精选时间');
			$table->bigInteger('words')->unsigned()->default(0)->comment('书籍的总字数');
			$table->boolean('is_sign')->default(0)->comment('书籍是否签约');
			$table->timestamp('sign_at')->nullable()->comment('书籍签约的时间');
			$table->timestamp('apply_sign_at')->nullable()->comment('书籍申请要签约的时间');
            $table->timestamps();
		});
	}


	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('books');
	}

}
